-
Notifications
You must be signed in to change notification settings - Fork 22
Build shared libraries by default, but honor BUILD_SHARED_LIBS #128
Conversation
Just as a side note: a user who wants to build individual packages without Have you tried to use static libraries when more than one rmw implementation is present? The reworked typesupport system relies on building shared libraries which are then dlopened at runtime (see ros2/rosidl#182). I would assume using static libraries won't work until a specialization is being implemented which bypasses that mechanism which will only be possible if only a single rmw impl. is present. |
@dirk-thomas I was under the assumption that building without Yes, I've built ROS2 statically with FastRTPS and OpenSplice, and typesupport libraries along with messages are built for both rmw implementations: $ find install_isolated/ -name "*.a"
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_generator_c.a
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.a
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.a
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.a
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_typesupport_opensplice_c.a
install_isolated//builtin_interfaces/lib/libbuiltin_interfaces__rosidl_typesupport_opensplice_cpp.a
install_isolated//fastcdr/lib/libfastcdr.a
install_isolated//fastrtps/lib/libfastrtps.a
install_isolated//rmw/lib/librmw.a
install_isolated//rmw_fastrtps_cpp/lib/librmw_fastrtps_cpp.a
install_isolated//rmw_opensplice_cpp/lib/librmw_opensplice_cpp.a
install_isolated//rosidl_generator_c/lib/librosidl_generator_c.a
install_isolated//rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.a
install_isolated//rosidl_typesupport_introspection_c/lib/librosidl_typesupport_introspection_c.a
install_isolated//rosidl_typesupport_introspection_cpp/lib/librosidl_typesupport_introspection_cpp.a
install_isolated//rosidl_typesupport_opensplice_c/lib/librosidl_typesupport_opensplice_c.a
install_isolated//rosidl_typesupport_opensplice_cpp/lib/librosidl_typesupport_opensplice_cpp.a
... Just for curiosity, what's the rationale for the typesupport refactor? The description doesn't state it and can't find a discussion about it (not saying that there isn't, just that I can't find it). |
Building ROS 2 without The original idea of the architecture was that the code above the rmw interface is agnostic to the used rmw implementation (see http://design.ros2.org/articles/ros_middleware_interface.html#why-should-the-middleware-interface-be-agnostic-to-dds). That is currently only true for the sources. But when the sources get built the whole stack from This results in a major overhead in every CMake file (e.g. see https://github.com/ros2/system_tests/blob/bc1dbab1787f7a77dcf1d25b329f5b3215e82b83/test_communication/CMakeLists.txt#L333 https://github.com/ros2/system_tests/blob/bc1dbab1787f7a77dcf1d25b329f5b3215e82b83/test_communication/CMakeLists.txt#L299-L303). And now we are moving forward on composition (building nodes as shared libraries as the recommended way to write ROS nodes and then loading them in a running process, see ros2/demos#84) and this burden becomes even more of a problem since the running process needs to select the matching library variation of a node which matches its rmw implementation. Therefore the goal is to get back to the original design that anything above rmw actually only needs to be built once. |
@dirk-thomas Ah, I see, thanks for the detailed explanation. It's unfortunate that this patch comes at a bad time, during all this refactoring. Maybe it's best to put this on hold until all the typesupport work is done and then find a way to accommodate the static linking usecase. |
@dirk-thomas just one question, wouldn't the static linking usecase be akin to manual composition (from the demos you linked)? That is, the user knows what For example, I picked FastRTPS in the iOS examples as the |
From my point of view the build tool should not set Therefore I don't think this patch should be merged into |
@dirk-thomas unfortunately the solution you describe doesn't seem to work (maybe I'm missing something) if the project creates libraries as shared explicitly. Given a CMake project like the following: project(foo)
add_library(${PROJECT_NAME} SHARED src/foo.cpp) the The scenario I have is as following:
so that's why I submitted this pull request, along with several others that remove the The changes in this PR allow the user to pass I made the changes in This is actually the same case as ros2/rmw#34 which @codebot submitted to disable shared linking, which is fairly common for embedded devices. This PR (and the accompanying PRs) extends that idea to the rest of the ROS2 up to |
If you could create a PR for the solution I described I am happy to take a look. Obviously each A question regarding iOS app: does it work for those apps to |
@dirk-thomas I see. Would the changes in ros2/rcl@8271e41 suffice? If
|
While that would work I don't think it is reasonable to expect every single package to perform that conditional
So as far as I understand the restrictions for iOS it won't work until we have completed the typesupport refactoring. Therefore I would suggest to wait with the shared / static library option until after that refactoring has been completed. Then we add a package (e.g. |
The new package Therefore I think this can be closed? |
@dirk-thomas thanks for adding |
I'll update the other branches to use |
@esteve we may lose track of the connected PRs now that this one is closed (disappearing in the waffle Done column) |
@mikaelarguedas I've created a new issue (ros2/ros2#306) to connect the corresponding PRs and updated their descriptions, hopefully it'll show up on appropriate column on the waffle board. |
This PR allows users to choose whether they want to build libraries as shared or as static via CMake's
BUILD_SHARED_LIBS
flag. IfBUILD_SHARED_LIBS
is not set,ament
will build libraries as shared.This is required for iOS, as it does not allow shared linking for apps, only static.